Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

270
Views
How to remove " from json nested value

How do I remove special char " in data and origin value below?

EDIT: I have added comma after blue before origin, the actual issue was how to make "[]" to [] after origin.

I want from this:

{ 
  "data" : "[{
    "color": "blue",
    "origin": "[{"state" : "USA"}, {"state" : "AFRICA"}]"
  }]"
}

To This:

{ 
  "data" : [{
    "color": "blue",
    "origin": [{"state" : "USA"}, {"state" : "AFRICA"}]
  }]
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

const strArr = "[{\"foo\": \"bar\"}]";
const arr = JSON.parse(strArr);
console.log(arr);

if that objects name is say "obj" you can do:

obj.data = JSON.parse(obj.data);

this will convert a valid json string into an array

Edit: if you are just trying to make origin an array instead of a string (assuming valid json) it is probably best you just JSON parse the whole thing then set origin to JSON.parse(origin)

let data = "[{\"color\": \"blue\", \"origin\": \"[{\\\"state\\\": \\\"USA\\\"},{\\\"state\\\": \\\"AFRICA\\\"}]\"}]";

let obj = {
  data: data
};

let objData = JSON.parse(obj.data);
objData[0].origin = JSON.parse(objData[0].origin);
console.log(objData);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!